﻿using System;
using System.Data;
using System.Data.OracleClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Xml;

using ESRI.ArcGIS.esriSystem;

/// <summary>
/// Utility 的摘要说明
/// </summary>
public class Utility
{

	public Utility()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}

    static public string hexToRGB(string hex)
    {
        Hashtable hexTable = new Hashtable();
        hexTable.Add("0", "0");
        hexTable.Add("1", "1");
        hexTable.Add("2", "2");
        hexTable.Add("3", "3");
        hexTable.Add("4", "4");
        hexTable.Add("5", "5");
        hexTable.Add("6", "6");
        hexTable.Add("7", "7");
        hexTable.Add("8", "8");
        hexTable.Add("9", "9");
        hexTable.Add("a", "10");
        hexTable.Add("b", "11");
        hexTable.Add("c", "12");
        hexTable.Add("d", "13");
        hexTable.Add("e", "14");
        hexTable.Add("f", "15");
        hex = hex.ToLower();
        if (hex.StartsWith("#"))
            hex = hex.Remove(0, 1);


        string hexR = hex.Substring(0, 2);
        string hexG = hex.Substring(2, 2);
        string hexB = hex.Substring(4, 2);

        string rgbR = (Convert.ToInt32(hexTable[hexR.Substring(0, 1)]) * 16 + Convert.ToInt32(hexTable[hexR.Substring(1, 1)])).ToString();
        string rgbG = (Convert.ToInt32(hexTable[hexG.Substring(0, 1)]) * 16 + Convert.ToInt32(hexTable[hexG.Substring(1, 1)])).ToString();
        string rgbB = (Convert.ToInt32(hexTable[hexB.Substring(0, 1)]) * 16 + Convert.ToInt32(hexTable[hexB.Substring(1, 1)])).ToString();
        return rgbR + "," + rgbG + "," + rgbB;
    }


    #region  初始化许可证
    public IAoInitialize m_AoInitialize = new ESRI.ArcGIS.esriSystem.AoInitializeClass();
    

    private esriLicenseStatus CheckOutLicenses(esriLicenseProductCode productCode)
    {
        esriLicenseStatus licenseStatus;

        //是否产品是可能的
        licenseStatus = m_AoInitialize.IsProductCodeAvailable(productCode);
        if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
        {

            //用相应的许可文件进行初始化
            licenseStatus = m_AoInitialize.Initialize(productCode);
        }
        return licenseStatus;
    }

    #endregion

}
